using System.IO;

namespace winsw
{
	public abstract class LogHandler
	{
		private EventLogger eventLogger;

		public EventLogger EventLogger
		{
			get
			{
				return eventLogger;
			}
			set
			{
				eventLogger = value;
			}
		}

		public abstract void log(Stream outputStream, Stream errorStream);

		protected void CopyStream(Stream i, Stream o)
		{
			byte[] array = new byte[1024];
			while (true)
			{
				bool flag = true;
				int num = i.Read(array, 0, array.Length);
				if (num == 0)
				{
					break;
				}
				o.Write(array, 0, num);
				o.Flush();
			}
			i.Close();
			o.Close();
		}

		protected void CopyFile(string sourceFileName, string destFileName)
		{
			try
			{
				File.Delete(destFileName);
				File.Move(sourceFileName, destFileName);
			}
			catch (IOException ex)
			{
				EventLogger.LogEvent("Failed to copy :" + sourceFileName + " to " + destFileName + " because " + ex.Message);
			}
		}
	}
}
